package ly.jobdu;

import java.util.ArrayList;
import java.util.Scanner;

public class Q1021CountingChar {
	public static void main(String[] args) {
		ArrayList<String> strings = new ArrayList<String>();
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String readline = scanner.nextLine();
			if (!(readline.equals("#"))) {
				strings.add(readline);
			} else {
				countingChar(strings);
				strings.clear();
			}
		}
	}

	public static void countingChar(ArrayList<String> strings) {
		for (int index = 0; index < strings.size(); index++) {
			if (index % 2 == 0) {
				char[] cs = strings.get(index).toCharArray();
				String str = strings.get(index + 1);
				char[] strs = str.toCharArray();
				
				for (int i = 0; i < cs.length; i++) {
					int count = 0;
					for (int j = 0; j < strs.length; j++) {
						if(strs[j] == cs[i]) {
							count = count + 1;
						}
					}
					System.out.print(cs[i] + " " + count);
					System.out.println();
				}
			}
		}
	}
}
